<!DOCTYPE html>
<html>

<head>

    {include file="Public/header"}
    <link href="__STATIC__/layout/css/gyq.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/layout/css/demo.css" type="text/css">
</head>

<body style="color:#333;padding:3px;">
<!-- 标题 -->
<div class="page-heade">
    <h2 class="title_color text-center">常用网点分组管理 </h2>
</div>
<!-- 标题 -->
<div class="form-inline">
    <form action="">
        <input type="hidden" name="jxs_id" value="{:request()->get('jxs_id')}">
        <table class="row-margin-top tab-content table-bordered table text-center" border="1">
            <tr>
                <td class="text-left" colspan="5" rowspan=""><a href="{:url('add')}?jxs_id={:request()->get('jxs_id')}"
                                                                class="btn btn-primary">新增常用网点分组</a></td>
            </tr>
            <tr>
                <td><label for="" class="form-label">分组名称：</label></td>
                <td class="text-left"><input type="text" class="form-control" name="title" value="{$title}"></td>
                <td>
                    <div class="form-group">
                        申请时间
                    </div>
                </td>
                <td class="text-left">
                    <div class="form-group">
                        <input type="text" id="start" placeholder="开始日期" class="form-control layer-date "
                               style="display: inline-block;" name="start" value="{$start}">
                    </div>
                    <div class="form-group">
                        至
                    </div>
                    <div class="form-group">
                        <input type="text" class="form-control layer-date" placeholder="结束日期"
                               style="display: inline-block;" id="end" name="end" value="{$end}">
                    </div>
                </td>
                <td class="text-left">
                    <button class="btn btn-info query">查询</button>
                    <button class="btn btn-info emptyIf" type="button" >清空查询条件</button>
                </td>
            </tr>
        </table>
    </form>
        <table class="table table-striped row-margin-top table-bordered text-center bud_hei">
            <tr class="info text-center">
                <th class="text-center">NO.</th>
                <th class="text-center">分组名称</th>
                <th class="text-center">申请人</th>
                <th class="text-center">申请时间</th>
                <th class="text-center">操作</th>
            </tr>
            {volist name="data" id="row"}
            <tr>
                <td>{$row.id}</td>
                <td>{$row.title}</td>
                <td>{$row.cusername}</td>
                <td>{$row.ctime}</td>
                <td>
                    <a href="{:url('update',['id'=>$row.id])}?jxs_id={:request()->get('jxs_id')}">修改</a>
                    <a href="{:url('delete',['id'=>$row.id])}?jxs_id={:request()->get('jxs_id')}" class="delete">删除</a>
                </td>
            </tr>
            {/volist}
            <tr>
                <td colspan="5">{$page}</td>
            </tr>
        </table>

</div>
<!-- 全局js -->
{include file="Public/footer"}
<!-- <script src="js/plugins/metisMenu/jquery.metisMenu.js"></script> -->
<script src="__STATIC__/layout/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script>
    $(function () {
        $('.delete').click(function () {
            var link = $(this).attr('href')
            swal({
                title: "您确定删除吗",
                text: "",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "确定",
                closeOnConfirm: false
            }, function (isConfirm) {
                if(isConfirm){
                    $.ajax({
                        'type':'post',
                        'url':link,
                        'dataType':'json',
                        'success':function (data) {
                            if(data.success){
                                swal({
                                    title:data.msg,
                                    type:'success'
                                },function () {
                                    location.reload()
                                })
                            }else
                                swal(data.msg, "", "error");
                        }
                    })
                }

            });
            return false
        });

        //日期范围限制
        var start = {
            elem: '#start',
            format: 'YYYY-MM-DD',
//        min: laydate.now(), //设定最小日期为当前日期
//        max: '2099-06-16 23:59:59', //最大日期
            istime: true,
            istoday: false,
            choose: function (datas) {
                end.min = datas; //开始日选好后，重置结束日的最小日期
                end.start = datas //将结束日的初始值设定为开始日
            }
        };
        var end = {
            elem: '#end',
            format: 'YYYY-MM-DD',
//        min: laydate.now(),
//        max: '2099-06-16 23:59:59',
            istime: true,
            istoday: false,
            choose: function (datas) {
                start.max = datas; //结束日选好后，重置开始日的最大日期
                $('#yjverifyTime').val(GetDateStr(datas,60))
            }
        };

        function GetDateStr(start,AddDayCount) {
            var dd = new Date(start);
            dd.setDate(dd.getDate()+AddDayCount);//获取AddDayCount天后的日期
            var y = dd.getFullYear();
            var m = dd.getMonth()+1;//获取当前月份的日期
            var d = dd.getDate();
            return y+"-"+m+"-"+d;
        }

        laydate(start);
        laydate(end);

        $('.emptyIf').on('click',function () {
            $(this).closest('form').find('input[type=text]').each(function () {
                $(this).val('')
            })
            $(this).closest('form').find('select').each(function () {
                $(this).val('')
            })
            $(this).closest('form').submit()
            return false
        })
    })
</script>
</body>

</html>
